package ar.com.larreta.entidades;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.SQLDelete;

@Entity
@Table(name = "email")
// Borrado logico
@SQLDelete (sql="UPDATE Email SET fechaEliminacion=CURRENT_TIMESTAMP WHERE ID=?")
// Solamente trae los que no fueron borrados
public class Email extends Entidad {

	private Long id;
	private TipoEmail tipoEmail;
	private String email;
	private PersonaLocalizable persona;
	
	@Id @GeneratedValue(strategy=GenerationType.AUTO)
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	@ManyToOne (fetch=FetchType.LAZY)
	@JoinColumn (name="idTipoEmail")
	public TipoEmail getTipoEmail() {
		return tipoEmail;
	}
	
	public void setTipoEmail(TipoEmail tipoEmail) {
		this.tipoEmail = tipoEmail;
	}
	
	@Basic @Column(name = "email")
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}

	@ManyToOne (fetch=FetchType.LAZY)
	@JoinColumn (name="idPersona")
	public PersonaLocalizable getPersona() {
		return persona;
	}

	public void setPersona(PersonaLocalizable persona) {
		this.persona = persona;
	}

}
